{% extends "TextBadger/base.html" %}

{% load customtags %}

{% block css %}
	<link rel="stylesheet" href="/static/TextBadger/css/projectpage.css">
{% endblock %}

{% block onDocLoad %}
        $('.menuitem').removeClass('menuitemselected');
        $("#mnuprojects").addClass("menuitemselected");

		$(".EditUserPermissions").multiselect({
			header: false,
			selectedText: "Select Permissions",
			noneSelectedText: "Select Permissions",
			height:"auto",
			minWidth:150,
			classes:"overflowshow widthinherit",
			click: function(event, ui){
				var value = ui.value;
				var add = ui.checked;
				var arr = value.split(",");
				var userproject = arr[0];
				var permission = arr[1];

				// POST REQUEST
				$.ajax({
                			type: "POST",
                			url: "/manageusers/",
                			data: "up=" + userproject + "&pid=" + permission + "&add=" + add,
        			});
			}
		});
{% endblock %}

{% block maincontent %}
	{% if not isHiddenProject %}
	<div id="PageHeading">
		<div id="PageName">{{ project.name }}
			{% if isadmin %}
			<a style='float:right;' class="button-base button-medium button-blue" onclick='return confirm("Are you sure you want to delete this project?")' href='/delete/project/?pid={{ pid }}'>Delete Project</a>
			{% endif %}
		</div>
		<div style='font-size:12px;width:285px;'>{{ project.description }}</div>
		<div class='ajaxlistcreator' style='font-size:12px;margin-top:10px;'>
			{% if manageusers or isadmin %}
                	<label class='fieldlabel'>Add Partner : </label>
                        <input style='margin-left:5px;width:200px;' type='text' id='partner' />
                        <a href='/search/user/?unique&addproj={{ project.id }}' style='font-size:14px;' class="ajaxpost button-base button-small button-blue">+</a>

                        <div style='margin:5px 0px 5px 0px;width:200px;' class="ui-corner-all negativeresponse hidden">
                        </div>
			
			<input type='hidden' name='partners' class='ajaxhiddenlist' value='{{ partnerids }}' />
			{% endif %}

                        <div style='margin-top:5px;width:285px;' class='ajaxlist'>
				Partners :
				{% for partner in partners %}
                                        <a href='/user/?uid={{ partner.user.id }}'>{{ partner.user.firstname }} {{ partner.user.lastname }}</a>
                                {% endfor %}
                        </div>
                </div>
	</div>

	<div id="PageContent">
		<!--
		<div class='Section'>
			<div class='SectionTitle'>Recent Activities</div>
			<div class='SectionContent'>
                	              <div class='SectionItem'>
                        	              <b>Today, 5PM</b><span class='SectionMargin'>Project learning finished</span>
                                      </div>
                                      <div class='SectionItem'>
                                              <b>Today, 4PM</b><span class='SectionMargin'>Document learning started</span>
                                      </div>
                                      <div class='SectionItem'>
                                              <b>Today, 3PM</b><span class='SectionMargin'>Abe finished labelling 250 documents</span>
                                      </div>
                                      <div class='SectionItem'>
                                              <b>Today, 2PM</b><span class='SectionMargin'>Mohit assigned 250 documents to Abe</span>
                                      </div>
                                      <div class='SectionItem'>
                                              <b>Yesterday, 1PM</b><span class='SectionMargin'>Mohit added Abe as a partner</span>
                                      </div>
                                      <div class='SectionItem'>
                                              <b>Yesterday, 12PM</b><span class='SectionMargin'>Mohit created Project</span>
                                      </div>
				</div>
                	</div>
		</div>
		-->
		{% if isadmin %}
		<div class='Section'>
                        <div class='SectionTitle'>Manage Project</div>
                        <div class='SectionContent'>
                        	<form action='/edit/project/' method='POST'>
                                	<div class='SectionItem'>
						<input type='hidden' name='pid' value='{{ project.id }}' />
                                        	<div>
                                                	<label class='fieldlabel' for='projectname' style="width:120px;">Project Name : </label>
                                                        <input type='text' required='required' name='pname' style="width:200px;" value="{{ project.name }}" />
                                                </div>

                                                <div>
                                                        <label class='fieldlabel' for='projectdesc' style="width:120px;">Description : </label>
                                                        <textarea name='pdesc' rows=6 style="width:200px;">{{ project.description }}</textarea>
                                                </div>

						<div>
                                                        <label class='fieldlabel' style="width:120px;">Privacy Settings : </label>
							<input type="radio" name="share" value="0" {% if project.shared_object.sharing_permission == 0 %}checked{% endif %}>Private
							<input type="radio" name="share" value="1" {% if project.shared_object.sharing_permission == 1 %}checked{% endif %}>Read to all
							<input type="radio" name="share" value="2" {% if project.shared_object.sharing_permission == 2 %}checked{% endif %}>Open Source
						</div>
                                         </div>
                                         <input type = "submit" class="button-base button-medium button-blue" id="btnUpdate" value="Update" onclick='if($("#pname").val() == "") return false;' />
                                 </form>
			</div>
                </div>
		{% endif %}

		<div class='Section'>
                        <div class='SectionTitle'>My Tasks</div>
                	{% if not usertasks %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>You dont have any pending task</div>
                                </div>
                        {% else %}
                        <div class='SectionContent'>
                                <table>
                                <tr>
                                <th style='padding-left:17px;width:22%;'>Name</th><th style="width:22%">Assigner</th>
                                <th style="width:23%;">Codebook</th><th style="width:22%;">Corpora</th><th style="width:11%;">Status</th>
                                </tr>

                                {% for task in usertasks %}
                                <tr>
                                <td style="width:22%;">
					{% if task.status != 1 %}<a href='/task/?tid={{ task.id }}' class='ui-icon ui-icon-pencil' title='Complete task' style='margin:0px;'></a>{% endif %}
                                        <span {% if task.status == 1 %}style="padding-left:17px;"{%endif %}>{{ task.name }}</span>
                                </td>
				<td style='width:22%'><span>{{ task.assigner.firstname }} {{ task.assigner.lastname }}</span></td>
                                <td style="width:23%;">{{ task.codebook.name }}</td>
                                <td style="width:22%;">{{ task.corpus.name }}</td>
                                <td style="width:11%;">{% if task.status == 1 %}<div class="positive nobg">Completed</div>{% else %}<div class="negative nobg">{{ task.num_docs|sub:task.num_docs_completed }} Docs left</div>{% endif %}</td>
                                </tr>
                                {% endfor %}
                                </table>
                        </div>
                        {% endif %}
		</div>
	
		{% if managetasks or isadmin %}	
		<div class='Section'>
                        <div class='SectionTitle'>
				Manage Tasks
				<a href='/new/task/?pid={{ project.id }}' class="dialogopener button-base button-small button-blue" style='float:right;' title='New Task'>New Task</a>
			</div>
			{% if not project.Tasks.all %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>No Tasks associated with this project</div>
                                </div>
                        {% else %}
                        <div class='SectionContent'>
                                <table>
                                <tr>
                               	<th style='padding-left:17px;width:18%;'>Name</th><th style='width:18%'>User</th><th style='width:18%'>Assigner</th>
                                <th style="width:18%;">Codebook</th><th style="width:17%;">Corpora</th><th style="width:11;">Status</th>
				</tr>
				
				{% for task in project.Tasks.all %}
                                <tr>
                                <td style="width:18%;">
                                        <a href='/remove/task/?tid={{ task.id }}' onclick='return confirm("Are you sure you want to delete this task?")' class='ui-icon ui-icon-closethick' title='Delete Task' style='margin:0px;'></a>
                                        <span>{{ task.name }}</span>
                                </td>
				<td style="width:18%"><span>{{ task.user.firstname }} {{ task.user.lastname }}</span></td>
				<td style="width:18%"><span>{{ task.assigner.firstname }} {{ task.assigner.lastname }}</span></td>
                                <td style="width:18%;">{{ task.codebook.name }}</td>
                                <td style="width:17%;">{{ task.corpus.name }}</td>
				<td style="width:11%;">{% if task.status == 1 %}<div class="positive nobg">Completed</div>{% else %}<div class="negative nobg">{{ task.num_docs|sub:task.num_docs_completed }} Docs left</div>{% endif %}</td>
                                </tr>
                                {% endfor %}
	                        </table>
                        </div>
			{% endif %}
                </div>
		{% endif %}

		{% if managecodebooks or isadmin %}
		<div class='Section'>
                        <div class='SectionTitle'>
                                Manage Codebooks
                                <a href='/new/codebook/?pid={{ project.id }}' class="button-base button-small button-blue dialogopener" style='float:right;' title='Create new Codebook'>New Codebook</a>
                        </div>
			{% if not project.Codebooks.all %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>No Codebooks associated with this project</div>
                                </div>
                        {% else %}
                	<div class='SectionContent'>
                        <table>
                                <tr>
                                <th style='padding-left:35px;width:32%;'>Codebook name</th>
				<th style="width:32%;">Creator</th><th style="width:22%;">Sharing Permissions</th><th style="width:11%;">Status</th>
                                </tr>

                                {% for codebook in project.Codebooks.all %}
                                <tr>
                                <td style="width:32%;">
					<a href='/remove/codebook/?cid={{ codebook.id }}' onclick='return confirm("Are you sure you want to delete this codebook?")' class='ui-icon ui-icon-closethick' title='Delete Codebook' style='margin:0px;'></a>
					<a href='/edit/codebook/?cid={{ codebook.id }}' class='dialogopener ui-icon ui-icon-pencil' title='Edit Codebook' style='margin:0px;'></a>
					<span>{{ codebook.name }}</span>
				</td>
				<td style="width:32%;">{{ codebook.user.firstname }} {{ codebook.user.lastname }}</td>
                                <td style="width:22%;">
                                        {% if codebook.shared_object.sharing_permission == 0 %}Private{% endif %}
                                        {% if codebook.shared_object.sharing_permission == 1 %}Read to all{% endif %}
                                        {% if codebook.shared_object.sharing_permission == 2 %}Open Source{% endif %}
                                </td>
				<td style="width:11%;">
                                        {% if codebook.status == 1 %}
					<div class="positive nobg">Active</div>
					{% else %}
						{% if codebook.status == 4 %}
						<div class="negative nobg">Invalid File</div>
						{% else %}
						<div class="neutral nobg">Processing</div>
						{% endif %}
					{% endif %}
                                </td>
                                </tr>
                                {% endfor %}
                        </table>
                        </div>
			{% endif %}
		</div>
		{% endif %}

		{% if managecorpus or isadmin %}
		<div class='Section'>
                        <div class='SectionTitle'>
                                Manage Corpus
                                <a href='/new/corpus/?pid={{ project.id }}' class="button-base button-small button-blue dialogopener" style='float:right;' title='Upload Corpus'>New Corpus</a>
                        </div>
			{% if not project.Corpora.all %}
				<div class='SectionContent'>
					<div class='highlight ui-state-highlight ui-corner-all'>No Corpora associated with this project</div>
				</div>
			{% else %}
			<div class='SectionContent'>
			<table>
                                <tr>
                                <th style='padding-left:35px;width:32%;'>Corpora name</th><th style="width:32%;">Uploader</th><th style="width:22%;">Sharing Permissions</th><th style="width:11%;">Status</th>
                                </tr>
				
				{% for corpus in project.Corpora.all %}
                                <tr>
                                <td style="width:32%;">
					<a href='/remove/corpora/?cid={{ corpus.id }}' onclick='return confirm("Are you sure you want to delete this corpora?")' class='ui-icon ui-icon-closethick' title='Delete Corpora' style='margin:0px;'></a>
                                        <a href='/edit/corpora/?cid={{ corpus.id }}' class='dialogopener ui-icon ui-icon-pencil' title='Edit Corpora' style='margin:0px;'></a>
					<span>{{ corpus.name }}</span>
				</td>
				<td style="width:32%;">{{ corpus.user.firstname }} {{ corpus.user.lastname }}</td>
				<td style="width:22%;">
					{% if corpus.shared_object.sharing_permission == 0 %}Private{% endif %}
					{% if corpus.shared_object.sharing_permission == 1 %}Read to all{% endif %}
					{% if corpus.shared_object.sharing_permission == 2 %}Open Source{% endif %}
				</td>
				<td style="width:11%;">
					{% if corpus.status == 1 %}
                                        <div class="positive nobg">Active</div>
                                        {% else %}
                                                {% if corpus.status == 4 %}
                                                <div class="negative nobg">Invalid File</div>
                                                {% else %}
                                                <div class="neutral nobg">Processing</div>
                                                {% endif %}
                                        {% endif %}
				</td>
                                </tr>
				{% endfor %}
                        </table>
			</div>
			{% endif %}
                </div>
		{% endif %}

		{% if manageusers or isadmin %}
		<div class='Section'>
                        <div class='SectionTitle'>
                                Manage Users
                        </div>
                        <div class='SectionContent'>
				{% if not project.Users.all %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>No Users other than you are associated with this project</div>
                                </div>
	                        {% else %}
				{% for projectuser in project.Users.all %}
				{% if user.id != projectuser.user.id %}
                                <div class='SectionItem clearfix'>
					<div style="float:right;width:190px;position:relative;">
                                                <select multiple="multiple" class="EditUserPermissions">
                                                        {% for permission in Permissions %}
                                                                <option value="{{ projectuser.id }},{{ permission.id }}" {% if permission in projectuser.permission.all %}selected="selected"{% endif %}>{{ permission.name }}</option>
                                                        {% endfor %}
                                                </select>
                                        </div>
					<div>
						<a href='/remove/partner/?pid={{ project.id }}&uid={{ projectuser.user.id }}' onclick='return confirm("Are you sure you want to delete this user from the project?")' class='ui-icon ui-icon-closethick' title='Remove User'></a>
						<span><b>{{ projectuser.user.firstname }} {{ projectuser.user.lastname }}</b></span>
					</div>	
                                </div>
				{% endif %}
				{% endfor %}
				{% endif %}
                        </div>
                </div>
		{% endif %}
		
		{% if managejobs or isadmin %}
                <div class='Section'>
                        <div class='SectionTitle'>
                                Scheduled Jobs
                                <a href='/new/job/?pid={{ project.id }}' class="button-base button-small button-blue dialogopener" style='float:right;' title='New Job'>New Job</a>                        
			</div>
			{% if not project.Jobs.all %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>No Jobs scheduled</div>
                                </div>
                        {% else %}
                        <div class='SectionContent'>
                        <table>
                                <tr>
                                <th style="padding-left:17px;width:18%;">Name</th><th style="width:18%;">Scheduler</th><th style="width:18%;">Tasks</th><th style="width:18%;">Classification Algo</th><th style="width:17%;">Vectorization Algo</th><th style="width:11%;">Status</th>
                                </tr>

                                {% for job in project.Jobs.all %}
                                <tr>
                                <td style="width:18%;">
                                        <a href='/remove/job/?jid={{ job.id }}' onclick='return confirm("Are you sure you want to delete this job?")' class='ui-icon ui-icon-closethick' title='Delete Job' style='margin:0px;'></a>
                                        <span>{{ job.name }}</span>
                                </td>
                                <td style="width:18%;">{{ job.user.firstname }} {{ job.user.lastname }}</td>
				<td style="width:18%;">{% for t in job.tasks.all %}{{ t.name }}, {% endfor %}</td>
				<td style="width:18%;">{{ job.classifier_algo.name }}</td>
				<td style="width:17%;">{{ job.vectorizer_algo.name }}</td>
                                <td style="width:11%;">
                                	{% if job.status == 1 %}
                                        <div class="positive nobg">Completed</div>
                                        {% else %}
                                                {% if job.status == 4 %}
                                                <div class="negative nobg">Error</div>
                                                {% else %}
                                                <div class="neutral nobg">Processing</div>
                                                {% endif %}
                                        {% endif %}
				</td>
                                </tr>
                                {% endfor %}
                        </table>
                        </div>
                        {% endif %}
                </div>
                {% endif %}

		{% if managereports or isadmin %}
                <div class='Section'>
                        <div class='SectionTitle'>
                                Manage Reports
                                <a href='/new/report/?pid={{ project.id }}' class="button-base button-small button-blue dialogopener" style='float:right;' title='New Report'>New Report</a>
                        </div>
			{% if not project.Reports.all %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>No Reports Generated</div>
                                </div>
                        {% else %}
                        <div class='SectionContent'>
                        <table>
                                <tr>
                                <th style='padding-left:17px;width:18%;'>Name</th><th style="width:18%;">Creator</th><th style="width:18%;">Job</th><th style="width:18%;">Generation Algo</th><th style="width:17%;">Sharing Permissions</th><th style="width:11%;">Status</th>
                                </tr>
                
                                {% for report in project.Reports.all %}
                                <tr>
                                <td style="width:18%;">
                                        <a href='/remove/report/?rid={{ report.id }}' onclick='return confirm("Are you sure you want to delete this report?")' class='ui-icon ui-icon-closethick' title='Delete Report' style='margin:0px;'></a>
                                        <span>{{ report.name }}</span>
                                </td>
				<td style="width:18%;">{{ report.user.firstname }} {{ report.user.lastname }}</td>
                                <td style="width:18%;">{{ report.job.name }}</td>
				<td style="width:18%;">{{ report.reportgenerator.name }}</td>
				<td style="width:17%;">
                                        {% if report.shared_object.sharing_permission == 0 %}Private{% endif %}
                                        {% if report.shared_object.sharing_permission == 1 %}Read to all{% endif %}
                                        {% if report.shared_object.sharing_permission == 2 %}Open Source{% endif %}
                                </td>
                                <td style="width:11%;">
                                	{% if report.status == 1 %}
                                        <div class="positive nobg">Completed</div>
                                        {% else %}
                                                {% if report.status == 4 %}
                                                <div class="negative nobg">Error</div>
                                                {% else %}
                                                <div class="neutral nobg">Processing</div>
                                                {% endif %}
                                        {% endif %}
				</td>
                                </tr>
                                {% endfor %}
                        </table>
                        </div>
                        {% endif %}
                </div>
                {% endif %}

		{% if managecorpusvectors or isadmin %}
                <div class='Section'>
                        <div class='SectionTitle'>
                                Manage Corpus Vectors
                        </div>
                        {% if not project.Vectors.all %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>No Corpus Vectors</div>
                                </div>
                        {% else %}
                        <div class='SectionContent'>
                        <table>
                                <tr>
                                <th style="padding-left:17px;width:40%;">Corpora</th><th style="width:40%;">Sharing Permissions</th><th style="width:18%;">Status</th>
                                </tr>

                                {% for vector in project.Vectors.all %}
                                <tr>
                                <td style="width:40%;">
                                        <a href='/remove/vector/?vid={{ vector.id }}' onclick='return confirm("Are you sure you want to delete this Corpus vector? It might be associated with an active Job.")' class='ui-icon ui-icon-closethick' title='Delete Vector' style='margin:0px;'></a>
                                        <span>{{ vector.corpus.name }}</span>
                                </td>
                                <td style="width:40%;">
                                        {% if vector.shared_object.sharing_permission == 0 %}Private{% endif %}
                                        {% if vector.shared_object.sharing_permission == 1 %}Read to all{% endif %}
                                        {% if vector.shared_object.sharing_permission == 2 %}Open Source{% endif %}
                                </td>
                                <td style="width:18%;">
                                	{% if vector.status == 1 %}
                                        <div class="positive nobg">Completed</div>
                                        {% else %}
                                                {% if vector.status == 4 %}
                                                <div class="negative nobg">Error</div>
                                                {% else %}
                                                <div class="neutral nobg">Processing</div>
                                                {% endif %}
                                        {% endif %}
				</td>
                                </tr>
                                {% endfor %}
                        </table>
                        </div>
			{% endif %}
                </div>
                {% endif %}

		{% if managevectorizeralgos or isadmin %}
                <div class='Section'>
                        <div class='SectionTitle'>
                                Manage Vectorizer Algorithms
				<a href='/new/algo/?type=v&pid={{ project.id }}' class="button-base button-small button-blue dialogopener" style='float:right;' title='Upload new algo'>Upload new Algo</a>
                        </div>
                        {% if not project.Vectorizers_Algo_Uploaded.all %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>No Vectorizers Algorithms uploaded</div>
                                </div>
                        {% else %}
                        <div class='SectionContent'>
                        <table>
                                <tr>
                                <th style="padding-left:35px;width:32%;">Name</th><th style="width:32%;">Uploader</th><th style="width:22%;">Sharing Permissions</th><th style="width:11%;">Status</th>
                                </tr>

                                {% for algo in project.Vectorizers_Algo_Uploaded.all %}
                                <tr>
                                <td style="width:32%;">
                                        <a href='/remove/algo/?type=v&aid={{ algo.id }}' onclick='return confirm("Are you sure you want to delete this Algorithm? It might be associated with an active Job.")' class='ui-icon ui-icon-closethick' title='Delete Vectorizer Algo' style='margin:0px;'></a>
					<a href='/edit/algo/?type=v&aid={{ algo.id }}' class='dialogopener ui-icon ui-icon-pencil' title='Edit Algo' style='margin:0px;'></a>
                                        <span>{{ algo.name }}</span>
                                </td>
				<td style="width:32%;">
					{{ algo.user.firstname }} {{ algo.user.lastname }}
				</td>
                                <td style="width:22%;">
                                        {% if algo.shared_object.sharing_permission == 0 %}Private{% endif %}
                                        {% if algo.shared_object.sharing_permission == 1 %}Read to all{% endif %}
                                        {% if algo.shared_object.sharing_permission == 2 %}Open Source{% endif %}
                                </td>
                                <td style="width:11%;">
                                	{% if algo.status == 1 %}
                                        <div class="positive nobg">Active</div>
                                        {% else %}
                                                {% if algo.status == 4 %}
                                                <div class="negative nobg">Invalid File</div>
                                                {% else %}
                                                <div class="neutral nobg">Processing</div>
                                                {% endif %}
                                        {% endif %}
				</td>
                                </tr>
                                {% endfor %}
                        </table>
                        </div>
                        {% endif %}
                </div>
                {% endif %}

		{% if manageclassifieralgos or isadmin %}
                <div class='Section'>
                        <div class='SectionTitle'>
                                Manage Classification Algorithms
				<a href='/new/algo/?type=c&pid={{ project.id }}' class="button-base button-small button-blue dialogopener" style='float:right;' title='Upload new algo'>Upload new Algo</a>
                        </div>
                        {% if not project.Classifiers_Algo_Uploaded.all %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>No Classification Algorithms uploaded</div>
                                </div>
                        {% else %}
                        <div class='SectionContent'>
                        <table>
                                <tr>
                                <th style="padding-left:35px;width:32%;">Name</th><th style="width:32%;">Uploader</th><th style="width:22%;">Sharing Permissions</th><th style="width:11%;">Status</th>
                                </tr>   

                                {% for algo in project.Classifiers_Algo_Uploaded.all %}
                                <tr>
                                <td style="width:32%;">
                                        <a href='/remove/algo/?type=c&aid={{ algo.id }}' onclick='return confirm("Are you sure you want to delete this Algorithm? It might be associated with an active Job.")' class='ui-icon ui-icon-closethick' title='Delete Classification Algo' style='margin:0px;'></a>
					<a href='/edit/algo/?type=c&aid={{ algo.id }}' class='dialogopener ui-icon ui-icon-pencil' title='Edit Algo' style='margin:0px;'></a>
                                        <span>{{ algo.name }}</span>
                                </td>
                                <td style="width:32%;">
                                        {{ algo.user.firstname }} {{ algo.user.lastname }}
                                </td>
                                <td style="width:22%;">
                                        {% if algo.shared_object.sharing_permission == 0 %}Private{% endif %}
                                        {% if algo.shared_object.sharing_permission == 1 %}Read to all{% endif %}
                                        {% if algo.shared_object.sharing_permission == 2 %}Open Source{% endif %}
                                </td>
                                <td style="width:11%;">
                                	{% if algo.status == 1 %}
                                        <div class="positive nobg">Active</div>
                                        {% else %}
                                                {% if algo.status == 4 %}
                                                <div class="negative nobg">Invalid File</div>
                                                {% else %}
                                                <div class="neutral nobg">Processing</div>
                                                {% endif %}
                                        {% endif %}
				</td>
                                </tr>
                                {% endfor %}
                        </table>
			</div>
                        {% endif %}
                </div>
                {% endif %}

		{% if managereportgenerators or isadmin %}
                <div class='Section'>
                        <div class='SectionTitle'>
                                Manage Report Generating Algorithms
				<a href='/new/algo/?type=r&pid={{ project.id }}' class="button-base button-small button-blue dialogopener" style='float:right;' title='Upload new algo'>Upload new Algo</a>
                        </div>
                        {% if not project.ReportGenerator_Algo_Uploaded.all %}
                                <div class='SectionContent'>
                                        <div class='highlight ui-state-highlight ui-corner-all'>No Report Generating Algorithms uploaded</div>
                                </div>
                        {% else %}
                        <div class='SectionContent'>
                        <table>
                                <tr>
                                <th style="padding-left:35px;width:32%;">Name</th><th style="width:32%;">Uploader</th><th style="width:22%;">Sharing Permissions</th><th style="width:11%;">Status</th>
                                </tr>   

                                {% for algo in project.ReportGenerator_Algo_Uploaded.all %}
                                <tr>
                                <td style="width:32%;">
                                        <a href='/remove/algo/?type=r&aid={{ algo.id }}' onclick='return confirm("Are you sure you want to delete this Algorithm? It might be associated with an active Job.")' class='ui-icon ui-icon-closethick' title='Delete Report Generator Algo' style='margin:0px;'></a>
					<a href='/edit/algo/?type=r&aid={{ algo.id }}' class='dialogopener ui-icon ui-icon-pencil' title='Edit Algo' style='margin:0px;'></a>
                                        <span>{{ algo.name }}</span>
                                </td>
                                <td style="width:32%;">
                                        {{ algo.user.firstname }} {{ algo.user.lastname }}
                                </td>
                                <td style="width:22%;">
                                        {% if algo.shared_object.sharing_permission == 0 %}Private{% endif %}
                                        {% if algo.shared_object.sharing_permission == 1 %}Read to all{% endif %}
                                        {% if algo.shared_object.sharing_permission == 2 %}Open Source{% endif %}
                                </td>
                                <td style="width:11%;">
                                	{% if algo.status == 1 %}
                                        <div class="positive nobg">Active</div>
                                        {% else %}
                                                {% if algo.status == 4 %}
                                                <div class="negative nobg">Invalid File</div>
                                                {% else %}
                                                <div class="neutral nobg">Processing</div>
                                                {% endif %}
                                        {% endif %}
				</td>
                                </tr>
                                {% endfor %}
                        </table>
			</div>
                        {% endif %}
                </div>
                {% endif %}

	</div>
	{% endif %}
{% endblock %}

